from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from meiduo_admin.views import admins
from meiduo_admin.views import groups
from meiduo_admin.views import image
from meiduo_admin.views import options
from meiduo_admin.views import orders
from meiduo_admin.views import permission
from meiduo_admin.views import skus
from meiduo_admin.views import specs
from meiduo_admin.views import spus
from meiduo_admin.views import statistical
from meiduo_admin.views import users

urlpatterns = [
    url(r'authorizations/', obtain_jwt_token),
    # 获取用户总量
    url(r'statistical/total_count/', statistical.UserCountView.as_view()),
    # 获取当天增加的用户
    url(r'statistical/day_increment/', statistical.UserDayCountView.as_view()),
    # 获取当天登陆的用户
    url(r'statistical/day_active/', statistical.UserActiveCountView.as_view()),
    # 获取当天登陆的用户
    url(r'statistical/day_orders/', statistical.UserOrderCountView.as_view()),
    # 获取当天登陆的用户
    url(r'statistical/month_increment/', statistical.UserMonthCountView.as_view()),
    # 获取当天登陆的用户
    url(r'statistical/goods_day_views/', statistical.GoodsDayView.as_view()),
    # 获取当天登陆的用户
    url(r'^users/', users.UserView.as_view()),
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    url(r'^skus/simple/$', image.ImageView.as_view({'get': 'simple'})),
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),
    url(r'^permission/groups/simple/$', admins.AdminView.as_view({'get': 'simple'})),
    url(r'^goods/specs/simple/$', options.OptionsView.as_view({'get': 'simple'})),
    # spu表
    url(r'^goods/brands/simple/$', spus.SPUSView.as_view({'get': 'brand'})),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SPUSView.as_view({'get': 'channels'})),
    url(r'^goods/channel/categories/$', spus.SPUSView.as_view({'get': 'channel'})),
    # url(r'^goods/images/$', spus.SPUSView.as_view({'post': 'image'})),
    # -----------------权限表管理------------------
    url(r'^permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),
    # 获取商品分类信息
    url(r'skus/categories/', skus.SKUCategorieView.as_view()),
    # 获取商品SPU表信息
    url(r'goods/simple/', skus.SPUSimpleView.as_view()),
    # 获取商品规格选项序列化信息
    url(r'goods/(?P<pk>\d+)/specs/', skus.SPUSpecView.as_view()),
]
#  ============   商品规格管理    ========
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='spec')
urlpatterns += router.urls

# ===========图片管理=========

router = DefaultRouter()
router.register('skus/images', image.ImageView, base_name='image')
urlpatterns += router.urls

# ===========订单管理=========

router = DefaultRouter()
router.register('orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

# ===========权限管理=========

router = DefaultRouter()
router.register('permission/perms', permission.PermissionView, base_name='perms')
urlpatterns += router.urls

# ===========用户组管理=========

router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls

# ===========管理员管理=========

router = DefaultRouter()
router.register('permission/admins', admins.AdminView, base_name='admins')
urlpatterns += router.urls

# ===========规格选项管理=========

router = DefaultRouter()
router.register('specs/options', options.OptionsView, base_name='options')
urlpatterns += router.urls
# ===========SKU表管理=========

router = DefaultRouter()
router.register('skus', skus.SKUGoodsView, base_name='skus')
urlpatterns += router.urls
# ===========SPU表管理=========

router = DefaultRouter()
router.register('goods', spus.SPUGoodsView, base_name='goods')
urlpatterns += router.urls



